var Panel = new Lang.Class({
Name: 'Panel',
+ Extends: St.Widget,
_init() {
- this.actor = new Shell.GenericContainer({ name: 'panel',
- reactive: true });
- this.actor._delegate = this;
- this.actor.set_offscreen_redirect(Clutter.OffscreenRedirect.ALWAYS);
+ this.parent({ name: 'panel',
+ reactive: true });
+
+ // For compatibility with extensions that still use the
+ // this.actor field
+ this.actor = this;
+ this.set_offscreen_redirect(Clutter.OffscreenRedirect.ALWAYS);
this._sessionStyle = null;
this.menuManager = new PopupMenu.PopupMenuManager(this);
this._leftBox = new St.BoxLayout({ name: 'panelLeft' });
- this.actor.add_actor(this._leftBox);
+ this.add_child(this._leftBox);
this._centerBox = new St.BoxLayout({ name: 'panelCenter' });
- this.actor.add_actor(this._centerBox);
+ this.add_child(this._centerBox);
this._rightBox = new St.BoxLayout({ name: 'panelRight' });
- this.actor.add_actor(this._rightBox);
+ this.add_child(this._rightBox);
this._leftCorner = new PanelCorner(St.Side.LEFT);
- this.actor.add_actor(this._leftCorner.actor);
+ this.add_child(this._leftCorner.actor);
this._rightCorner = new PanelCorner(St.Side.RIGHT);
- this.actor.add_actor(this._rightCorner.actor);
+ this.add_child(this._rightCorner.actor);
- this.actor.connect('get-preferred-width', this._getPreferredWidth.bind(this));
- this.actor.connect('get-preferred-height', this._getPreferredHeight.bind(this));
- this.actor.connect('allocate', this._allocate.bind(this));
- this.actor.connect('button-press-event', this._onButtonPress.bind(this));
- this.actor.connect('touch-event', this._onButtonPress.bind(this));
- this.actor.connect('key-press-event', this._onKeyPress.bind(this));
+ this.connect('button-press-event', this._onButtonPress.bind(this));
+ this.connect('touch-event', this._onButtonPress.bind(this));
+ this.connect('key-press-event', this._onKeyPress.bind(this));
Main.overview.connect('showing', () => {
- this.actor.add_style_pseudo_class('overview');
+ this.add_style_pseudo_class('overview');
this._updateSolidStyle();
});
Main.overview.connect('hiding', () => {
- this.actor.remove_style_pseudo_class('overview');
+ this.remove_style_pseudo_class('overview');
this._updateSolidStyle();
});
- Main.layoutManager.panelBox.add(this.actor);
- Main.ctrlAltTabManager.addGroup(this.actor, _("Top Bar"), 'focus-top-bar-symbolic',
+ Main.layoutManager.panelBox.add(this);
+ Main.ctrlAltTabManager.addGroup(this, _("Top Bar"), 'focus-top-bar-symbolic',
{ sortGroup: CtrlAltTab.SortGroup.TOP });
Main.sessionMode.connect('updated', this._updatePanel.bind(this));
global.window_group.connect('actor-removed', this._onWindowActorRemoved.bind(this));
global.window_manager.connect('switch-workspace', this._updateSolidStyle.bind(this));
- global.display.connect('workareas-changed', () => { this.actor.queue_relayout(); });
+ global.display.connect('workareas-changed', () => { this.queue_relayout(); });
this._updatePanel();
},
this._updateSolidStyle();
},
- _getPreferredWidth(actor, forHeight, alloc) {
+ vfunc_get_preferred_width(actor, forHeight) {
let primaryMonitor = Main.layoutManager.primaryMonitor;
- alloc.min_size = -1;
-
if (primaryMonitor)
- alloc.natural_size = primaryMonitor.width;
- else
- alloc.natural_size = -1;
- },
+ return [0, primaryMonitor.width];
- _getPreferredHeight(actor, forWidth, alloc) {
- // We don't need to implement this; it's forced by the CSS
- alloc.min_size = -1;
- alloc.natural_size = -1;
+ return [0, 0];
},
- _allocate(actor, box, flags) {
+ vfunc_allocate(box, flags) {
+ this.parent(box, flags);
+
let allocWidth = box.x2 - box.x1;
let allocHeight = box.y2 - box.y1;
centerWidth = centerNaturalWidth;
// get workspace area and center date entry relative to it
- let monitor = Main.layoutManager.findMonitorForActor(actor);
+ let monitor = Main.layoutManager.findMonitorForActor(this);
let centerOffset = 0;
if (monitor) {
let workArea = Main.layoutManager.getWorkAreaForMonitor(monitor.index);
childBox.y1 = 0;
childBox.y2 = allocHeight;
- if (this.actor.get_text_direction() == Clutter.TextDirection.RTL) {
+ if (this.get_text_direction() == Clutter.TextDirection.RTL) {
childBox.x1 = Math.max(allocWidth - Math.min(Math.floor(sideWidth),
leftNaturalWidth),
0);
childBox.y1 = 0;
childBox.y2 = allocHeight;
- if (this.actor.get_text_direction() == Clutter.TextDirection.RTL) {
+ if (this.get_text_direction() == Clutter.TextDirection.RTL) {
childBox.x1 = 0;
childBox.x2 = Math.min(Math.floor(sideWidth),
rightNaturalWidth);
if (this._sessionStyle)
this._addStyleClassName(this._sessionStyle);
- if (this.actor.get_text_direction() == Clutter.TextDirection.RTL) {
+ if (this.get_text_direction() == Clutter.TextDirection.RTL) {
this._leftCorner.setStyleParent(this._rightBox);
this._rightCorner.setStyleParent(this._leftBox);
} else {
},
_updateSolidStyle() {
- if (this.actor.has_style_pseudo_class('overview') || !Main.sessionMode.hasWindows) {
+ if (this.has_style_pseudo_class('overview') || !Main.sessionMode.hasWindows) {
this._removeStyleClassName('solid');
return;
}
});
/* Check if at least one window is near enough to the panel */
- let [, panelTop] = this.actor.get_transformed_position();
- let panelBottom = panelTop + this.actor.get_height();
+ let [, panelTop] = this.get_transformed_position();
+ let panelBottom = panelTop + this.get_height();
let scale = St.ThemeContext.get_for_stage(global.stage).scale_factor;
let isNearEnough = windows.some(metaWindow => {
let verticalPosition = metaWindow.get_frame_rect().y;
},
_addStyleClassName(className) {
- this.actor.add_style_class_name(className);
+ this.add_style_class_name(className);
this._rightCorner.actor.add_style_class_name(className);
this._leftCorner.actor.add_style_class_name(className);
},
_removeStyleClassName(className) {
- this.actor.remove_style_class_name(className);
+ this.remove_style_class_name(className);
this._rightCorner.actor.remove_style_class_name(className);
this._leftCorner.actor.remove_style_class_name(className);
},